package com.zhang.zhangapp.view.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zhang.zhangapp.R;
import com.zhang.zhangapp.bean.shop.ShopType;

import java.util.List;

/**
 * Created by Administrator on 2018/4/15.
 */

public class ShopTypeAdapter extends BaseAdapter {

    private List<ShopType> shopTypeList;
    private Context context;
    private int textBackgroundRes = -1;

    public ShopTypeAdapter(List<ShopType> shopTypeList, Context context) {
        this.shopTypeList = shopTypeList;
        this.context = context;
    }

    public ShopTypeAdapter(List<ShopType> shopTypeList, Context context, int textBackgroundRes) {
        this.shopTypeList = shopTypeList;
        this.context = context;
        this.textBackgroundRes = textBackgroundRes;
    }

    @Override
    public int getCount() {
        return shopTypeList == null ? 0 : shopTypeList.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        TextView textView = null;
        view = LayoutInflater.from(context).inflate(R.layout.item_shop_type, null);
        textView = view.findViewById(R.id.item_shop_type);
        if (textBackgroundRes != -1) {
            textView.setBackgroundResource(textBackgroundRes);
        }
        textView.setText(shopTypeList.get(i).getName());
        return view;
    }
}
